# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_pyname=oslo_i18n
_realname=oslo-i18n
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=6.5.1
pkgrel=1
pkgdesc="Oslo i18n library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-oslo-i18n'
  'purl: pkg:pypi/oslo-i18n'
)
msys2_repository_url='https://opendev.org/openstack/oslo.i18n/'
msys2_changelog_url='https://docs.openstack.org/releasenotes/oslo.i18n/'
msys2_documentation_url='https://docs.openstack.org/oslo.i18n/latest/'
msys2_issue_tracker_url='https://bugs.launchpad.net/oslo.i18n/'
url='https://docs.openstack.org/oslo.i18n/latest'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-pbr")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('ea856a70c5af7c76efb6590994231289deabe23be8477159d37901cef33b109d')

build() {
  # Set version for python_pbr
  export PBR_VERSION=$pkgver

  cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
